package edu.yctc.manage.entity;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author zyj
 * @Description 返回数据
 * @Date 14:42 2021/3/29
 * @Param
 * @return
 **/

public class ResultDO extends HashMap<String, Object> {
    private static final long serialVersionUID = 1L;

    public ResultDO() {
        put("code", 0);
    }

    public static ResultDO error() {
        return error(500, "未知异常，请联系管理员");
    }

    public static ResultDO error(String msg) {
        return error(500, msg);
    }

    public static ResultDO error(int code, String msg) {
        ResultDO resultDO = new ResultDO();
        resultDO.put("code", code);
        resultDO.put("msg", msg);
        return resultDO;
    }

    public static ResultDO ok(String msg) {
        ResultDO resultDO = new ResultDO();
        resultDO.put("msg", msg);
        return resultDO;
    }

    public static ResultDO ok(Map<String, Object> map) {
        ResultDO resultDO = new ResultDO();
        resultDO.putAll(map);
        return resultDO;
    }

    public static ResultDO ok() {
        return new ResultDO();
    }

    public ResultDO put(String key, Object value) {
        super.put(key, value);
        return this;
    }
}
